*
* Table 3: The Prevalence and Private Cost of Dominated Choices
*
* Input table: 
*	/"${data_applicant_level_tidy}"
*
* Output file: 
*	/results/Table3.tex
*

use "${data_applicant_level_tidy}", clear

* Restrict to the eligible sample
keep if eligibility == 1 & any_ba_listed == 1 & no_funded_version_at_all == 0

cap file close sumstat
file open sumstat using "${result_dir}/Table3.tex", write replace
file write sumstat "\begin{tabular}{l c c c} \\ \hline\hline" _n
file write sumstat " & \multicolumn{1}{c}{Dropping} & \multicolumn{1}{c}{Flipping} & \multicolumn{1}{c}{Total}  \\ " _n
file write sumstat " & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)}  \\ \hline " _n

count if dominated_dropping_applicant_id == 1
local nobs_drop: display %12.0gc r(N)
count if dominated_flipping_applicant_id == 1
local nobs_flip: display %12.0gc r(N)
count if (dominated_dropping_applicant_id == 1 | dominated_flipping_applicant_id == 1)
local nobs_choice: display %12.0gc r(N)

file write sumstat "Dominated choices &  `nobs_drop' & `nobs_flip' & `nobs_choice' \\ " _n

count if costly_dominated_drop_DA_id == 1
local nobs_drop: display %12.0gc r(N)
count if costly_dominated_flip_DA_id  == 1
local nobs_flip: display %12.0gc r(N)
count if (costly_dominated_drop_DA_id == 1 | costly_dominated_flip_DA_id == 1)
local nobs_choice: display %12.0gc r(N)

file write sumstat "Ex post costly dominated choices -- lower bound &  `nobs_drop' & `nobs_flip' & `nobs_choice' \\ " _n

count if costly_dominated_drop_id == 1
local nobs_drop: display %12.0gc r(N)
count if costly_dominated_flip_id  == 1
local nobs_flip: display %12.0gc r(N)
count if (costly_dominated_drop_id == 1 | costly_dominated_flip_id == 1)
local nobs_choice: display %12.0gc r(N)

file write sumstat "Ex post costly dominated choices -- upper bound &  `nobs_drop' & `nobs_flip' & `nobs_choice' \\ \hline\hline " _n
file write sumstat "\end{tabular}" _n
file close sumstat

* ------------------------------------------------------------------------------	
* Table notes:
count
local n_obs = r(N)
di "The table presents the prevalence and cost of revealed flipping, revealed dropping and all revealed dominated choices among eligible applicants " `n_obs'  "."
